/*
 * Copyright (C) 2011-2012 Adam Gregoire <bsdunx@gmail.com>
 * Copyright (C) 2011-2012 Jeff Hubbard <lord2800@gmail.com>
 *
 * This file is part of the ScriptKit scripting engine library.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef __DEBUG_HPP__
#define __DEBUG_HPP__ 1

// FIXME fml ..

#ifdef _DEBUG
# if defined OS_WIN32 && defined _CRTDBG_MAP_ALLOC

#include <cstdlib>
#include <crtdbg.h>

int __cdecl CrtDebugReportHook(int nRptType, char *szMsg, int *retVal);

#define DEBUG_NEW new(_NORMAL_BLOCK, THIS_FILE, __LINE__)

#define MALLOC_DBG(x) _malloc_dbg(x, 1, THIS_FILE, __LINE__);
#define malloc(x) MALLOC_DBG(x)

#  define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#  define new DEBUG_NEW

# endif // OS_WIN32 && _CRTDBG_MAP_ALLOC
#endif // _DEBUG

#endif /* __DEBUG_HPP__ */
